/*

Author   : chaos

FileName : class_type_con.cpp

Date     : 13/08/17 13:16:31

*/
#include <iostream>
#include <cstring>
using namespace std;

class String
{
    private:
        char * string;
        long len;
        friend void call_by_value(String);

    public:
        String(const char *);
        operator char * ()
        {
            cout << "Type convert operator is called" << endl;
            return string;
        }
};

String::String(const char * i_string)
{
    cout << "Type convert constructor is called!" << endl;
    len = strlen(i_string);
        string = new char [len = 1];
    strcpy(string,i_string);
}


void call_by_value(String str)
{ cout << str.string << endl; }

void type_con(char * str)
{
    cout << str << endl;
}



int main(int argc ,char *argv[])
{
    String A_String("My String");

    call_by_value("test");

    type_con(A_String);
    return 0;
}
